package
{

public dynamic class MyMath
{
    static var PiRads: Number = 0.0174532925199;

    function MyMath()
    {
    }

    static function getDistance(x0, y0, x1, y1)
    {
        return Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
    }

    static function getAngle(x0, y0, x1, y1)
    {
        var __reg1 = Math.atan2(y1 - y0, x1 - x0) / MyMath.PiRads;
        if (__reg1 < 0) 
        {
            __reg1 = __reg1 + 360;
        }
        if (__reg1 > 360) 
        {
            __reg1 - 360;
        }
        return __reg1;
    }

    static function doLinesCross(p0, p1, p2, p3)
    {
        return MyMath.CCW(p0, p1, p2) * MyMath.CCW(p0, p1, p3) <= 0 && MyMath.CCW(p2, p3, p0) * MyMath.CCW(p2, p3, p1) <= 0;
    }

    static function CCW(p0, p1, p2)
    {
        var __reg5 = p1.x - p0.x;
        var __reg3 = p2.x - p0.x;
        var __reg4 = p1.y - p0.y;
        var __reg2 = p2.y - p0.y;
        return __reg5 * __reg2 <= __reg4 * __reg3 ? -1 : 1;
    }

    static function whereDoLinesCross(a, b, c, d)
    {
        var __reg5 = ((a.y - c.y) * (d.x - c.x) - (a.x - c.x) * (d.y - c.y)) / ((b.x - a.x) * (d.y - c.y) - (b.y - a.y) * (d.x - c.x));
        var __reg8 = a.x + __reg5 * (b.x - a.x);
        var __reg7 = a.y + __reg5 * (b.y - a.y);
        var __reg6 = new Point(__reg8, __reg7);
        return __reg6;
    }

}


}